Listing 3. Code for DS_uidAndPwd written by Dreamweaver MX

 
<MM:DataSet 
id="DS_uidAndPwd"
runat="Server"
IsStoredProcedure="false"
ConnectionString='<%# System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_STRING_security"] %>'
DatabaseType='<%# System.Configuration.ConfigurationSettings.AppSettings["MM_CONNECTION_DATABASETYPE_security"] %>'
CommandText='<%# "SELECT emailaddr, password  FROM dbo.members WHERE emailaddr=@emailaddr AND password=@password" %>'
Debug="true"
> 
  <Parameters> 
    <Parameter Name="@emailaddr" 
   Value='<%# ((Request.Form["emailaddr"] != null) && (Request.Form["emailaddr"].Length > 0)) ? Request.Form["emailaddr"] : ""  %>'  
   Type="VarChar"   /> 
    <Parameter  Name="@password" 
   Value='<%# ((Request.Form["password"] != null) && (Request.Form["password"].Length > 0)) ? Request.Form["password"] : ""  %>'  
   Type="VarChar"   /> 
  </Parameters>
</MM:DataSet>
 

Notes:

  • id – the name of the DS_uidAndPwd dataset.
  • IsStoredProcedure – if false, then the CommandText is an SQL statement. If true, the CommandText is the name of a stored procedure.
  • ConnectionString and DatabaseType – are set when you select the connection in the dialog.
  • The two <Parameter> tags correspond to the two pieces of the WHERE clause in the SELECT statement.

Another random but hard-learned lesson: you can't split a long binding expression over multiple lines. Take for example, the CommandText attribute above:

 
CommandText='<%# "SELECT emailaddr, password  FROM dbo.members WHERE emailaddr=@emailaddr AND password=@password" %>'
 

You may be tempted to break this into multiple lines for easier readability because it's so long. No can do: You'll get a runtime error. Everything within the binding expression has to be on the same line, even if it's god-awful long.